#ifndef __LOG_HPP__
#define __LOG_HPP__

/* Log模块：日志打印模块。 */

#include <ctime>

/* 日志等级 */
#define NORMAL 0
#define DEBUG  1
#define INFO   2
#define ERROR  3
#define DEFAULT_LEVEL DEBUG

/* 日志宏 */
#define LOG(level, format, ...) \
    do\
    {\
        if(level < DEFAULT_LEVEL) break;\
        time_t timer = time(nullptr);\
        struct tm* now_time = localtime(&timer);\
        char time_buf[32] = { 0 };\
        strftime(time_buf, 31, "%Y/%m/%d-%H:%M:%S", now_time);\
        fprintf(stdout, "[%p][%s][%s:%d]" format "\n", (void*)pthread_self(), time_buf, __FILE__, __LINE__, ##__VA_ARGS__);\
    }\
    while (0)

#define NRL_LOG(format, ...) LOG(NORMAL, format, ##__VA_ARGS__)
#define DBG_LOG(format, ...) LOG(DEBUG, format, ##__VA_ARGS__)
#define INF_LOG(format, ...) LOG(INFO, format, ##__VA_ARGS__)
#define ERR_LOG(format, ...) LOG(ERROR, format, ##__VA_ARGS__)

#endif